<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>flash.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_useragent_flash.js.html">flash.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Flash detection.
<a name="line17"></a> * @see ../demos/useragent.html
<a name="line18"></a> */
<a name="line19"></a>
<a name="line20"></a>goog.provide(&#39;goog.userAgent.flash&#39;);
<a name="line21"></a>
<a name="line22"></a>goog.require(&#39;goog.string&#39;);
<a name="line23"></a>
<a name="line24"></a>
<a name="line25"></a>/**
<a name="line26"></a> * @define {boolean} Whether we know at compile-time that the browser doesn&#39;t
<a name="line27"></a> * have flash.
<a name="line28"></a> */
<a name="line29"></a>goog.userAgent.flash.ASSUME_NO_FLASH = false;
<a name="line30"></a>
<a name="line31"></a>
<a name="line32"></a>/**
<a name="line33"></a> * Whether we can detect that the browser has flash
<a name="line34"></a> * @type {boolean}
<a name="line35"></a> * @private
<a name="line36"></a> */
<a name="line37"></a>goog.userAgent.flash.detectedFlash_ = false;
<a name="line38"></a>
<a name="line39"></a>
<a name="line40"></a>/**
<a name="line41"></a> * Full version information of flash installed, in form 7.0.61
<a name="line42"></a> * @type {string}
<a name="line43"></a> * @private
<a name="line44"></a> */
<a name="line45"></a>goog.userAgent.flash.detectedFlashVersion_ = &#39;&#39;;
<a name="line46"></a>
<a name="line47"></a>
<a name="line48"></a>/**
<a name="line49"></a> * Initializer for goog.userAgent.flash
<a name="line50"></a> *
<a name="line51"></a> * This is a named function so that it can be stripped via the jscompiler if
<a name="line52"></a> * goog.userAgent.flash.ASSUME_NO_FLASH is true.
<a name="line53"></a> * @private
<a name="line54"></a> */
<a name="line55"></a>goog.userAgent.flash.init_ = function() {
<a name="line56"></a>  if (navigator.plugins &amp;&amp; navigator.plugins.length) {
<a name="line57"></a>    var plugin = navigator.plugins[&#39;Shockwave Flash&#39;];
<a name="line58"></a>    if (plugin) {
<a name="line59"></a>      goog.userAgent.flash.detectedFlash_ = true;
<a name="line60"></a>      if (plugin.description) {
<a name="line61"></a>        goog.userAgent.flash.detectedFlashVersion_ =
<a name="line62"></a>            goog.userAgent.flash.getVersion_(plugin.description);
<a name="line63"></a>      }
<a name="line64"></a>    }
<a name="line65"></a>
<a name="line66"></a>    if (navigator.plugins[&#39;Shockwave Flash 2.0&#39;]) {
<a name="line67"></a>      goog.userAgent.flash.detectedFlash_ = true;
<a name="line68"></a>      goog.userAgent.flash.detectedFlashVersion_ = &#39;2.0.0.11&#39;;
<a name="line69"></a>    }
<a name="line70"></a>
<a name="line71"></a>  } else if (navigator.mimeTypes &amp;&amp; navigator.mimeTypes.length) {
<a name="line72"></a>    var mimeType = navigator.mimeTypes[&#39;application/x-shockwave-flash&#39;];
<a name="line73"></a>    goog.userAgent.flash.detectedFlash_ = mimeType &amp;&amp; mimeType.enabledPlugin;
<a name="line74"></a>    if (goog.userAgent.flash.detectedFlash_) {
<a name="line75"></a>      goog.userAgent.flash.detectedFlashVersion_ =
<a name="line76"></a>          goog.userAgent.flash.getVersion_(mimeType.enabledPlugin.description);
<a name="line77"></a>    }
<a name="line78"></a>
<a name="line79"></a>  } else {
<a name="line80"></a>    /** @preserveTry */
<a name="line81"></a>    try {
<a name="line82"></a>      // Try 7 first, since we know we can use GetVariable with it
<a name="line83"></a>      var ax = new ActiveXObject(&#39;ShockwaveFlash.ShockwaveFlash.7&#39;);
<a name="line84"></a>      goog.userAgent.flash.detectedFlash_ = true;
<a name="line85"></a>      goog.userAgent.flash.detectedFlashVersion_ =
<a name="line86"></a>          goog.userAgent.flash.getVersion_(ax.GetVariable(&#39;$version&#39;));
<a name="line87"></a>    } catch (e) {
<a name="line88"></a>      // Try 6 next, some versions are known to crash with GetVariable calls
<a name="line89"></a>      /** @preserveTry */
<a name="line90"></a>      try {
<a name="line91"></a>        var ax = new ActiveXObject(&#39;ShockwaveFlash.ShockwaveFlash.6&#39;);
<a name="line92"></a>        goog.userAgent.flash.detectedFlash_ = true;
<a name="line93"></a>        // First public version of Flash 6
<a name="line94"></a>        goog.userAgent.flash.detectedFlashVersion_ = &#39;6.0.21&#39;;
<a name="line95"></a>      } catch (e2) {
<a name="line96"></a>        /** @preserveTry */
<a name="line97"></a>        try {
<a name="line98"></a>          // Try the default activeX
<a name="line99"></a>          var ax = new ActiveXObject(&#39;ShockwaveFlash.ShockwaveFlash&#39;);
<a name="line100"></a>          goog.userAgent.flash.detectedFlash_ = true;
<a name="line101"></a>          goog.userAgent.flash.detectedFlashVersion_ =
<a name="line102"></a>              goog.userAgent.flash.getVersion_(ax.GetVariable(&#39;$version&#39;));
<a name="line103"></a>        } catch (e3) {
<a name="line104"></a>          // No flash
<a name="line105"></a>        }
<a name="line106"></a>      }
<a name="line107"></a>    }
<a name="line108"></a>  }
<a name="line109"></a>};
<a name="line110"></a>
<a name="line111"></a>
<a name="line112"></a>/**
<a name="line113"></a> * Derived from Apple&#39;s suggested sniffer.
<a name="line114"></a> * @param {string} desc e.g. Shockwave Flash 7.0 r61.
<a name="line115"></a> * @return {string} 7.0.61.
<a name="line116"></a> * @private
<a name="line117"></a> */
<a name="line118"></a>goog.userAgent.flash.getVersion_ = function(desc) {
<a name="line119"></a>  var matches = desc.match(/[\d]+/g);
<a name="line120"></a>  matches.length = 3;  // To standardize IE vs FF
<a name="line121"></a>  return matches.join(&#39;.&#39;);
<a name="line122"></a>};
<a name="line123"></a>
<a name="line124"></a>
<a name="line125"></a>if (!goog.userAgent.flash.ASSUME_NO_FLASH) {
<a name="line126"></a>  goog.userAgent.flash.init_();
<a name="line127"></a>}
<a name="line128"></a>
<a name="line129"></a>
<a name="line130"></a>/**
<a name="line131"></a> * Whether we can detect that the browser has flash
<a name="line132"></a> * @type {boolean}
<a name="line133"></a> */
<a name="line134"></a>goog.userAgent.flash.HAS_FLASH = goog.userAgent.flash.detectedFlash_;
<a name="line135"></a>
<a name="line136"></a>
<a name="line137"></a>/**
<a name="line138"></a> * Full version information of flash installed, in form 7.0.61
<a name="line139"></a> * @type {string}
<a name="line140"></a> */
<a name="line141"></a>goog.userAgent.flash.VERSION = goog.userAgent.flash.detectedFlashVersion_;
<a name="line142"></a>
<a name="line143"></a>
<a name="line144"></a>/**
<a name="line145"></a> * Whether the installed flash version is as new or newer than a given version.
<a name="line146"></a> * @param {string} version The version to check.
<a name="line147"></a> * @return {boolean} Whether the installed flash version is as new or newer
<a name="line148"></a> *     than a given version.
<a name="line149"></a> */
<a name="line150"></a>goog.userAgent.flash.isVersion = function(version) {
<a name="line151"></a>  return goog.string.compareVersions(goog.userAgent.flash.VERSION,
<a name="line152"></a>                                     version) &gt;= 0;
<a name="line153"></a>};
</pre>


</body>
</html>
